package com.itheima.hash.hashmap;

import java.util.HashMap;
import java.util.TreeMap;

/*
HashMap
不是一个线程安全的容器
 */
public class Demo02 {


    public static void main(String[] args) throws InterruptedException {
        TreeMap<String, String> map = new TreeMap<>();

        new Thread(()->{
            //操作map的代码
            for (int i = 0; i < 250; i++) {
                map.put(i+"",i+"");
            }
        }).start();
        new Thread(()->{
            //操作map的代码
            for (int i = 250; i < 500; i++) {
                map.put(i+"",i+"");
            }
        }).start();


        Thread.sleep(1000);
        for (int i = 0; i < 500; i++) {
            System.out.println(i+"====="+map.get(i+""));
        }

    }
}
